home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / test / testxid.c < prev   
Encoding:
C/C++ Source or Header  |  1992-08-27  |  1.1 KB  |  56 lines

  1. /*
  2.  * testxid.c --
  3.  *    Transaction id test code.
  4.  */
  5.  
  6. #include "fmgr.h"    /* for M_STATIC/M_DYNAMIC */
  7.  
  8. #include <stdio.h>
  9.  
  10. #include "c.h"
  11.  
  12. #include "xid.h"
  13.  
  14. RcsId("$Header: /private/postgres/src/test/RCS/testxid.c,v 1.3 1989/09/05 16:55:09 mao Version_2 $");
  15.  
  16. TestMain()
  17. {
  18.     char        buffer[80];
  19.     TransactionId    xid;
  20.     int        i;
  21.     static bool    beenHere = false;
  22.  
  23.     if (beenHere) {
  24.         elog(1 /* FATAL */, "testxid: error occurred");
  25.     } else {
  26.         beenHere = true;
  27.     }
  28.     StartTransactionCommand();
  29.  
  30.     xid = GetNewTransactionId();
  31.  
  32.     printf("The \"first\" xid is %s\n", TransactionIdFormString(xid));
  33.     printf("The next twenty xids are");
  34.  
  35.     for (i = 0; i < 20; i += 1) {
  36.         xid = GetNewTransactionId();
  37.         printf(" %s", TransactionIdFormString(xid));
  38.     }
  39.     printf("\n");
  40.  
  41.     for (i = 0; i < 3456; i += 1) {
  42.         xid = GetNewTransactionId();
  43.     }
  44.     printf("The 3456th next xid is %s\n", TransactionIdFormString(xid));
  45.  
  46.     for (;;) {
  47.         printf("Please enter a xid: ");
  48.         if (scanf("%s", buffer) < 1) {
  49.             break;
  50.         }
  51.         xid = StringFormTransactionId(buffer);
  52.         printf("You entered %s\n\n", TransactionIdFormString(xid));
  53.     }
  54.     printf("Done!\n");
  55. }
  56.